<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('成长记录列表')" />
    <link th:href="@{/ImageView/viewer.min.css}" rel="stylesheet"/>
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 select-table table-striped">
                <input type="hidden" id="pid" th:value="${pid}"/>
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
     <script th:src="@{/ImageView/viewer.min.js}"></script>
     <script th:src="@{/ImageView/viewer-jquery.min.js}"></script>
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('wechat:WxPoultryGrowth:edit')}]];
        var removeFlag = [[${@permission.hasPermi('wechat:WxPoultryGrowth:remove')}]];
        var prefix = ctx + "wechat/WxPoultryGrowth";

        $(function() {
            var options = {
                url: prefix + "/list?growthPid="+$("#pid").val(),
                removeUrl: prefix + "/remove",
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                modalName: "成长记录",
                columns: [
                {
                    field: 'growthId',
                    title: '编号',
                    visible: false,
                    sortable: false
                },
                {
                    field: 'growthType',
                    title: '饲料类型',
                    sortable: false
                },
                {
                    field: 'growthRemark',
                    title: '喂养备注',
                    sortable: false
                },
                {
                    field: 'growthPiclist',
                    title: '图集',
                    sortable: false,
                    formatter: function(value, row, index) {
                        if(value==null){
                            return "无"
                        }else {
                            return '<span><a onclick="openPicList(\''+row.growthPiclist+'\',\''+row.growthId+'\')">查看图片</a></span>'
                        }
                    }
                },
                {
                    field: 'growthKg',
                    title: '当前重量',
                    sortable: false
                },
                {
                    field: 'growthTime',
                    title: '喂养时间',
                    sortable: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.growthId + '\')">删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function openPicList(str,id){
            $("#picList").empty();
            var arr = str.split(",");
            var html = "<div style='display: none' id='div_"+id+"'>"

            for(var i=0;i<arr.length;i++){
                html+="<img class='pic' src='"+arr[i]+"'>"
            }
            html+="</div>"
            $("#picList").append(html)
            var view =  new Viewer(document.getElementById('div_'+id), {
                url: 'data-original'
            });
            $(".pic").click();
        }
    </script>
</body>
</html>
